@use "../../../colors";

.compose-comment {
    margin-left: .5rem;
    width: 100%;

    .compose-error-row {
        width: 100%;
        justify-content: flex-start;

        .compose-error-tip {
            margin-bottom: .5rem;
            border: 1px solid colors.$active-gray;
            border-radius: 5px;
            background-color: colors.$ui-orange;
            padding: .25rem;
            width: 100%;
            text-align: left;
            color: colors.$type-white;
            font-size: .85rem;
        }
    }

    .full-width-form {
        width: 100%;
    }

    .textarea-row {
        width: 100%;

        textarea {
            &:not(:focus) {
                border: 2px solid colors.$active-dark-gray;
            }
        }
    }

    .compose-bottom-row {
        width: 100%;
        margin-top: 0.4rem;
        justify-content: space-between;
        flex-direction: row;

        .compose-post {
            margin-right: .5rem;
        }

        .compose-cancel {
            background-color: colors.$ui-dark-gray;
        }

        .compose-limit {
            margin-left: auto;
            height: 100%;
            font-size: .75rem;
        }

        .button {
            margin-left: 0;
            margin-top: 0;
            margin-bottom: 0;
            border-radius: .25rem;
        }
    }
}

.comment-container {
    position: relative;
    width: 100%;
    justify-content: flex-end;
}

.comment {
    position: relative;
    width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: space-between;
    align-items: flex-start;

    &.highlighted-comment:before {
        position: absolute;
        top: -.5rem;
        left: -.5rem;
        border-radius: .5rem;
        background: colors.$ui-blue-10percent;
        width: calc(100% + 1rem);
        height: 100%;
        content: "";
        
        /* 
            Because this :before is absolutely positioned, it will eat clicks
            from non-absolute elements after it (like the author link).
            Prevent this by explicitly disabling pointer events on this background element.
        */
        pointer-events: none;
    }

    .comment-top-row {
        margin-bottom: 8px;
        width: 100%;
        flex-direction: row;

        .username {
            margin-right: auto;
        }

        .comment-delete,
        .comment-report,
        .comment-restore {
            opacity: .5;
            cursor: pointer;
            font-size: .75rem;
            font-weight: 500;

            &:before {
                display: inline-block;
                margin-right: .5rem;
                background-repeat: no-repeat;
                background-position: center center;
                background-size: contain;
                content: "";
            }
        }

        .comment-visibility {
            opacity: .5;
            font-size: .75rem;
        }

        .comment-delete {
            margin-right: 1rem;

            &:before {
                background-image: url("/svgs/project/delete-gray.svg");
                width: 1rem;
                height: 1rem;
                vertical-align: -.25rem;
            }
        }

        .comment-report {
            &:before {
                margin-right: .25rem;
                background-image: url("/svgs/project/report-gray.svg");
                width: .75rem;
                height: .75rem;
                vertical-align: -.125rem;
            }
        }

        .comment-restore {
            margin-left: 1rem;

            &:before {
                margin-right: .25rem;
                background-image: url("/svgs/project/restore-gray.svg");
                width: .75rem;
                height: .75rem;
                vertical-align: -.125rem;
            }
        }
    }

    .avatar {
        margin-right: .5rem;
        border-radius: 4px;
        box-shadow: 0px 0px 0px 1px rgba(77, 151, 255, 0.25);
        width: 3rem;
        height: 3rem;
    }

    .comment-body {
        margin-bottom: 1.5rem;
        min-width: 50%;
        flex-grow: 1;
        align-items: flex-start;

        .comment-bubble {
            position: relative;
            margin-left: .5rem;
            border: 1px solid colors.$active-gray;
            border-radius: 0 .5rem .5rem .5rem;
            background-color: colors.$ui-white;
            padding: .75rem;
            width: calc(100% - .5rem);
            box-sizing: border-box;

            &:before {
                display: inline-block;
                position: absolute;
                top: -1px;
                left: -11px; // width + 1px
                border-width: 1px 0 1px 1px;
                border-style: solid;
                border-radius: 0 0 0 8px;
                border-color: colors.$active-gray transparent colors.$active-gray colors.$active-gray;
                background: colors.$ui-white;
                width: 10px;
                height: 9px;
                content: "";
            }

            &.comment-bubble-reported {
                $reported-outline:  #ff6680;
                $reported-background: rgb(236, 206, 223);

                border-color: $reported-outline;
                background-color: $reported-background;

                &:before {
                    border-color: $reported-outline transparent $reported-outline $reported-outline;
                    background: $reported-background;
                }
            }

            &.comment-bubble-markedbyfilter {
                $markedbyfilter-outline:  colors.$ui-yellow;
                $markedbyfilter-background: rgb(255, 254, 210);

                border-color: $markedbyfilter-outline;
                background-color: $markedbyfilter-background;

                &:before {
                    border-color: $markedbyfilter-outline transparent $markedbyfilter-outline $markedbyfilter-outline;
                    background: $markedbyfilter-background;
                }
            }
        }

        .comment-content {
            font-size: 1rem;
            line-height: 1.5rem;
            overflow-wrap: break-word;
            display: block;
            overflow: hidden;
        }

        .comment-bottom-row {
            padding-top: 1rem;
            font-size: .75rem;
            flex-direction: row;
            justify-content: space-between;

            .comment-time {
                color: colors.$ui-dark-gray;
            }

            .comment-reply {
                display: inline-flex;
                cursor: pointer;
                color: colors.$link-purple;
                font-weight: bold;

                &:after {
                    margin-left: .25rem;
                    background-image: url("/svgs/project/comment-reply.svg");
                    background-size: cover;
                    width: 1rem;
                    height: 1rem;
                    content: "";
                }
            }
        }
    }

}

.replies {
    width: calc(100% - 4rem);

    .comment-reply-row {
        margin-left: -3.5rem;
        width: calc(100% + 3.5rem);
    }
}

.replies.collapsed > .comment:last-of-type {
    &:after {
        position: absolute;
        bottom: 0;
        background: linear-gradient(
            colors.$ui-light-primary-transparent,
            colors.$ui-light-primary
        );
        width: 100%;
        height: 100%;
        content: "";
        pointer-events: none;
    }
}

.thread-limit-status {
    width: calc(100% - 4rem);
    margin-left: auto;
    
    .comment-status-icon {
        display: none;
    }
}

.compose-disabled {
    opacity: .5;
}

.comments-root-reply {
    margin-bottom: 2rem;
}

.comment-reply-row {
    margin-top: 2rem;
    margin-bottom: .5rem;
    margin-left: .5rem;
    width: calc(100% - 0.5rem);
}

.expand-thread {
    margin-bottom: 24px;
    width: 100%;
    overflow: hidden;
    text-align: center;

    &:before,
    &:after {
        display: inline-block;
        position: relative;
        background-color: colors.$active-gray;
        width: 50%;
        height: 2px;
        vertical-align: middle;
        content: "";
    }

    &:before {
        right: .5em;
        margin-left: -50%;
    }

    &:after {
        left: .5em;
        margin-right: -50%;
    }
}

/* Hide the action list buttons (delete/report/restore) until hover over */
.comment .action-list { opacity: 0; }
.comment:hover .action-list { opacity: 1; }
